<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>对象解构</title>
</head>
<body>
  <script>
    /**
     * 1. 解构
     * 2. 别名
     * 3. 默认值/回滚值
    */

    // 1. 解构
    const family = {
      father: 'father',
      mother: 'mother',
      sister: 'sister',
    }
    const { father, mother, sister } = family;
    console.log('解构', father, mother, sister);

    // 2.别名
    const { father: f, mother: m, sister: s } = family;
    console.log('别名', f, m, s);

    // 3. 默认值/回滚值
    const { father: ff, mother: mm, sister: ss, grandfather = 'grandfather', grandmother = 'grandmother' } = family;
    console.log('赋值/回滚值', ff, mm, ss, grandfather, grandmother);
  </script>
</body>
</html>